package com.csgc.camera.biz.vip

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import com.csgc.camera.base.LazyFragment
import com.csgc.camera.bean.VipEquitiesPageData
import com.cysd.spsyxj.R
import com.cysd.spsyxj.databinding.FragmentVipEquitiesPageBinding


import com.elvishew.xlog.XLog

class VipEquitiesFragment:LazyFragment<FragmentVipEquitiesPageBinding>() {

    companion object{
        private const val KEY_PAGE_DATA = "pageData"
        private const val KEY_POSITION = "position"
        fun getInstance(data:VipEquitiesPageData,position:Int):VipEquitiesFragment{
           val fragment =  VipEquitiesFragment()
           val bundle = Bundle()
            bundle.putInt(KEY_POSITION,position)
            bundle.putParcelable(KEY_PAGE_DATA,data)
            fragment.arguments = bundle
            return fragment
        }
    }
    override fun bindingInflater(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): FragmentVipEquitiesPageBinding {
        return FragmentVipEquitiesPageBinding.inflate(inflater,container,false)
    }

    private val pageData:VipEquitiesPageData? by lazy {
        arguments?.getParcelable(KEY_PAGE_DATA)
    }
    private val position:Int by lazy {
        arguments?.getInt(KEY_POSITION,1)?:1
    }
    override fun lazyInit() {


    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.tvTitle.text = pageData?.title
        binding.tvPageNum.text = "$position"
        binding.tvDesc.text = pageData?.des
        binding.ivMaskImage.setImageResource(pageData?.image?: R.drawable.img_vip_page_1)
    }
}